// Author: combacsa@kaist.ac.kr
// http://www.jungol.co.kr/prog/Hanal/hanalView.php?qs_code=2581
// Parametric Search

//#define COMPILE_P2581
#ifdef COMPILE_P2581

#include <fstream>
#include <algorithm>

using namespace std;

int n, m;
int data[10000];
int sum[10000];
int maximum = 0;
int answer = 0;

void input() {
	ifstream in("input.txt");
	in >> n;
	for (int i = 0; i < n; i++) {
		in >> data[i];
		if (maximum < data[i]) {
			maximum = data[i];
		}
	}
	in >> m;
	in.close();
}

void solve() {
	int min = 0;
	while (min <= maximum) {
		int value = (maximum + min) / 2;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			if (value > data[i]) {
				sum += data[i];
			} else {
				sum += value;
			}
		}
		if (sum <= m) {
			if (answer < value) {
				answer = value;
			}
			min = value + 1;
		} else {
			maximum = value - 1;
		}
	}
}

void output() {
	ofstream out("output.txt");
	out << answer << "\n";
	out.close();
}

int main() {
	input();
	solve();
	output();
    return 0;
}


#endif
